package flex.persistence {
	import flex.persistence.criteria.*;

	public interface EntityManager {
		/**		
		 * Check if the instance belongs to the current persistence context.
		 */
		function contains(entity:Object, transaction:EntityTransaction):Boolean;
		/**		
		 * Returns the resource-level transaction object.
		 */
		function getTransaction():EntityTransaction;
		/**		
		 * Find by primary key.
		 */
		function find(entityClass:Class, primaryKey:Object, transaction:EntityTransaction=null):*;
		/**		
		 * Merge the state of the given entity into the current persistence context.
		 */
		function merge(entity:*, transaction:EntityTransaction=null):*;
		/**		
		 * Make an entity instance managed and persistent.
		 */
		function persist(entity:Object, transaction:EntityTransaction=null):void;
		/**		
		 * Refresh the state of the instance from the database, overwriting changes made to the entity, if any.
		 */
		function refresh(entity:Object, transaction:EntityTransaction=null):void;
		/**		
		 * Remove the entity instance.
		 */
		function remove(entity:Object, transaction:EntityTransaction=null):void;

//		Partiellement implementé
		/**		
		 * Create an instance of Query for executing a native SQL query.
		 */
		function createNativeQueryForClass(sqlString:String, resultClass:Class, transaction:EntityTransaction=null):Query
		/**		
		 * Create an instance of Query for executing a Flex Persistence query language statement.
		 */
		function createQuery(qlString:String, transaction:EntityTransaction=null):Query;

		function createSqlQuery(criteriaQuery:CriteriaQuery):String
		
//		A implementer
		/**
		 * Create an instance of CriteriaBuilder for executing Criteria query
		 */
		function getCriteriaBuilder(transaction:EntityTransaction = null):CriteriaBuilder;
		
		/**		
		 * Create an instance of Query for executing a named query (in the Java Persistence query language or in native SQL).
		 */
		//		function createNamedQuery(name:String):Query;
		/**		
		 * Create an instance of Query for executing a native SQL query.
		 */
		//function createNativeQuery(sqlString:String, resultSetMapping:String=null):Query;
		
		function createTypedQuery(query:CriteriaQuery):Query;
		
		
		
//		A voir
		/**		
		 * Clear the persistence context, causing all managed entities to become detached.
		 */
//		function clear():void;
		/**		
		 * Close an application-managed EntityManager.
		 */
//		function close():void;
		/**		
		 * Synchronize the persistence context to the underlying database.
		 */
//		function flush():void;
		/**		
		 * Return the underlying provider object for the EntityManager, if available.
		 */
//		function getDelegate():Object;
		/**		
		 * Get the flush mode that applies to all objects contained in the persistence context.
		 */
//		function getFlushMode():FlushModeType;
		/**		
		 * Determine whether the EntityManager is open.
		 */
//		function isOpen():Boolean;
		/**		
		 * Indicate to the EntityManager that a JTA transaction is active.
		 */
//		function joinTransaction():void;
		/**		
		 * Set the lock mode for an entity object contained in the persistence context.
		 */
//		function lock(entity:Object, lockMode:LockModeType):void;
		/**		
		 * Set the flush mode that applies to all objects contained in the persistence context.		
		 */
//		function setFlushMode(flushMode:FlushModeType):void;

		
//		Inutiles
		/**		
		 * Get an instance, whose state may be lazily fetched.
		 */
//		function getReference(entityClass:Class, primaryKey:Object, transaction:EntityTransaction=null):*;
	}
}